<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script type="application/javascript" src="../layui/layui.js"></script>
    <style type="text/css">
        #bg {
            position: fixed;
            left: 0;
            top: 0;
            height: 50%;
            width: 100%;
            z-index: -1;
            background-color: pink;
        }
        #app {
            width: 600px;
            height: 620px;
            min-height: 320px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }
        .layui-form-item {
            margin-left: 230px;
            margin-top: 15px;
        }
        .left {
            font-family: 幼圆;
        }
        .right {
            margin-top: 60px;
            margin-left: 230px;
        }
    </style>
</head>
<body>
<div id="bg"></div>
<div data-v-676ecf83="" id="app">
    <div data-v-95c8bc32="" data-v-676ecf83="" class="header2">
        <div data-v-95c8bc32="" class="layout clear">
            <h1 data-v-95c8bc32="" class="left">欢迎注册</h1>
        </div>
    </div>

    <div data-v-676ecf83="" class="register">
        <div data-v-676ecf83="" class="layout">
            <div data-v-676ecf83="" class="registerCom clear">
                <div data-v-676ecf83="" class="registerType left">
                   <!-- <h3 data-v-676ecf83="">新用户注册</h3>-->
                    <form class="layui-form" method="post">
                        <div class="layui-form-item">
                            <i class="layui-icon layui-icon-cellphone" style="font-size: 20px;"></i>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" name="account" lay-verify="account" placeholder="请输入账户"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <i class="layui-icon layui-icon-password" style="font-size: 20px;"></i>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="password" name="password" lay-verify="password"
                                           placeholder="请输入6-12位密码" autocomplete="on" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <i class="layui-icon layui-icon-username" style="font-size: 20px;"></i>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" name="name" lay-verify="name"
                                           placeholder="请输姓名" autocomplete="on" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <i class="layui-icon layui-icon-cellphone" style="font-size: 20px;"></i>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="tel" name="tel" lay-verify="required|phone" placeholder="请输入手机号"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div data-v-676ecf83="" class="registerImg right">
                    <h3 data-v-676ecf83="">已有账号？
                        <a data-v-676ecf83="" href="login.html">立即登录&nbsp;&gt;&gt;</a>
                    </h3>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form'], function () {
        //初始化
        var form = layui.form;
        //自定义验证规则
        form.verify({
            password: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            /*,repassword: function(value) {
               var repassvalue = $('#password').val();
               if(value != repassvalue){
                   return '两次输入的密码不一致！'
               }
            }*/
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            $.ajax({
                url: "../hospital/register.do",
                type: "post",
                data: $("form").serialize(),
                dataType: 'json',
                success: function (res) {
                    if (res.code == 1) {
                        alert("注册成功！");
                        window.location.href = ("../before/login.html");
                    } else {
                        layer.alert(res.info);
                    }
                },
                error: function () {
                    elert("ajax错误");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>